<template>


  <div class="navbar" mode="horizontal">
    <Breadcrumb class="breadcrumb-container"/>
    <div class="right-menu"> 
      <el-dropdown class="avatar-container right-menu-item">
        <div class="avatar-wrapper">
          <img src="../../assets/set.png" class="user-avatar"/>
          <i class="el-icon-caret-bottom"/>
        </div>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item divided @click="loginOut">登出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {ref} from 'vue'
import {useRouter} from 'vue-router'
import { ElMessageBox} from 'element-plus'
import store from '../../store'
import Breadcrumb from './Breadcrumb.vue'
import {removeToken} from "../../utils/auth";
import {loginOutApi} from "../../api/login";

const router = useRouter()



const fromEditVisible = ref(false)
function Cancel() {
  fromEditVisible.value = false
}

const BtnConfirmAble = ref(false)

const loginOut = () => {
  ElMessageBox.confirm('退出登录', '提示', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'warning'
  })
      .then(() => {
        router.push('/login')
        loginOutApi().then((res:any)=>{
          if (res.success==true){
            router.push('/login')
          }
        })
      })
      .catch(() => {
      })
}


</script>

<style lang="scss" scoped>
.navbar {
  height: 50px;
  overflow: hidden;
  line-height: 50px;

  .hamburger-container {
    float: left;
    height: 50px;
    padding: 0 10px;
  }

  .breadcrumb-container {
    float: left;
  }

  .errLog-container {
    display: inline-block;
    vertical-align: top;
  }

  :deep(.right-menu) {
    display: flex;
    align-items: center;
    float: right;
    height: 100%;

    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      margin: 0 4px;
      vertical-align: middle;
    }

    .international {
      vertical-align: top;
    }

    .theme-switch {
      vertical-align: 15px;
    }

    .avatar-container {
      // height: 50px;
      margin-right: 30px;

      .avatar-wrapper {
        position: relative;
        margin-top: 5px;

        .user-avatar {
          width: 40px;
          height: 40px;
          cursor: pointer;
          border-radius: 10px;
        }

        .el-icon-caret-bottom {
          position: absolute;
          top: 20px;
          right: -16px;
          font-size: 12px;
        }
      }
    }
  }
}
</style>
